//
//  ViewController.m
//  生成二维码
//
//  Created by zhouLiHuan on 2017/1/17.
//  Copyright © 2017年 zhouLiHuan. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()


@property (nonatomic,strong)UIImageView *QRCodeImgView; //二维码view
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(20, 50,200, 50);
    btn.backgroundColor = [UIColor yellowColor];
    [btn setTitle:@"点击出现二维码" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
    
    
    }

//点击按钮 出现二维码
- (void)btnClick:(UIButton *)btn{
    btn.enabled = NO;
    
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    imgView.center = self.view.center;
    imgView.backgroundColor = [UIColor whiteColor];
    self.QRCodeImgView = imgView;
    [self.view addSubview:imgView];
    
    //获取内置滤镜的种类
    NSLog(@"内置滤镜的种类 %@",[CIFilter filterNamesInCategory:kCICategoryBuiltIn]);
    CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
    //设置默认值
    [filter setDefaults];
    
    NSLog(@"inputKey %@",filter.inputKeys);
    //封装数据 字符串
    [filter setValue:[@"itunes.apple.com/us/app/zhi-fu-bao-rang-sheng-huo/id333206289?mt=8" dataUsingEncoding:NSUTF8StringEncoding] forKey:@"inputMessage"];
    
    //放大原图
    CIImage *resultImage = [filter.outputImage imageByApplyingTransform:CGAffineTransformMakeScale(5, 5)];
    self.QRCodeImgView.image  = [UIImage imageWithCIImage:resultImage];
}

/*
 
 内置滤镜的种类 (
 CIAccordionFoldTransition,
 CIAdditionCompositing, //影像合成
 CIAffineClamp,
 CIAffineTile,
 CIAffineTransform, //仿射变换
 CIAreaAverage,
 CIAreaHistogram,
 CIAreaMaximum,
 CIAreaMaximumAlpha,
 CIAreaMinimum,
 CIAreaMinimumAlpha,
 CIAztecCodeGenerator,
 CIBarsSwipeTransition,
 CIBlendWithAlphaMask,
 CIBlendWithMask,
 CIBloom,
 CIBoxBlur,
 CIBumpDistortion,
 CIBumpDistortionLinear,
 CICheckerboardGenerator, //棋盘发生器
 CICircleSplashDistortion,
 CICircularScreen,
 CICircularWrap,
 CIClamp,
 CICMYKHalftone,
 CICode128BarcodeGenerator,
 CIColorBlendMode,  //CIColor的混合模式
 CIColorBurnBlendMode, //CIColor的燃烧混合模式
 CIColorClamp,
 CIColorControls,
 CIColorCrossPolynomial,
 CIColorCube,  //立方体
 CIColorCubeWithColorSpace,
 CIColorDodgeBlendMode,  //CIColor的避免混合模式
 CIColorInvert, //CIColor 相反
 CIColorMap,
 CIColorMatrix, //CIColor 矩阵
 CIColorMonochrome,  //黑白照
 CIColorPolynomial,
 CIColorPosterize,
 CIColumnAverage,
 CIComicEffect,
 CIConstantColorGenerator, //恒定颜色发生器
 CIConvolution3X3,
 CIConvolution5X5,
 CIConvolution7X7,
 CIConvolution9Horizontal,
 CIConvolution9Vertical,
 CICopyMachineTransition,
 CICrop,         //裁剪
 CICrystallize,
 CIDarkenBlendMode,   //亮度混合模式
 CIDepthOfField,
 CIDifferenceBlendMode,  //差分混合模式
 CIDiscBlur,
 CIDisintegrateWithMaskTransition,
 CIDisplacementDistortion,
 CIDissolveTransition,
 CIDivideBlendMode,
 CIDotScreen,
 CIDroste,
 CIEdges,
 CIEdgeWork,
 CIEightfoldReflectedTile,
 CIExclusionBlendMode,  //互斥混合模式
 CIExposureAdjust, //曝光调节
 CIFalseColor,    //伪造颜色
 CIFlashTransition,
 CIFourfoldReflectedTile,
 CIFourfoldRotatedTile,
 CIFourfoldTranslatedTile,
 CIGammaAdjust,   //灰色系数调节
 CIGaussianBlur,    //高斯模糊效果
 CIGaussianGradient,  //高斯梯度
 CIGlassDistortion,
 CIGlassLozenge,
 CIGlideReflectedTile,
 CIGloom,
 CIHardLightBlendMode,  //强光混合模式
 CIHatchedScreen,
 CIHeightFieldFromMask,
 CIHexagonalPixellate,
 CIHighlightShadowAdjust,  //高亮阴影调节
 CIHistogramDisplayFilter,
 CIHoleDistortion,
 CIHueAdjust,   //饱和度调节
 CIHueBlendMode, //饱和度混合模式
 CIHueSaturationValueGradient,
 CIKaleidoscope,
 CILanczosScaleTransform,
 CILenticularHaloGenerator,
 CILightenBlendMode,
 CILightTunnel,
 CILinearBurnBlendMode,
 CILinearDodgeBlendMode,
 CILinearGradient,   //线性梯度
 CILinearToSRGBToneCurve,
 CILineOverlay,
 CILineScreen,
 CILuminosityBlendMode,  //亮度混合模式
 CIMaskedVariableBlur,
 CIMaskToAlpha,
 CIMaximumComponent,
 CIMaximumCompositing,  //最大合成
 CIMedianFilter,
 CIMinimumComponent,
 CIMinimumCompositing,  //最小合成
 CIModTransition,
 CIMotionBlur,
 CIMultiplyBlendMode,   //多层次混合模式
 CIMultiplyCompositing,   //多层合成
 CINinePartStretched,
 CINinePartTiled,
 CINoiseReduction,
 CIOpTile,
 CIOverlayBlendMode,  //覆盖叠加混合模式
 CIPageCurlTransition,
 CIPageCurlWithShadowTransition,
 CIParallelogramTile,
 CIPDF417BarcodeGenerator,
 CIPerspectiveCorrection,
 CIPerspectiveTile,
 CIPerspectiveTransform,
 CIPerspectiveTransformWithExtent,
 CIPhotoEffectChrome,
 CIPhotoEffectFade,
 CIPhotoEffectInstant,
 CIPhotoEffectMono,
 CIPhotoEffectNoir,
 CIPhotoEffectProcess,
 CIPhotoEffectTonal,
 CIPhotoEffectTransfer,
 CIPinchDistortion,
 CIPinLightBlendMode,
 CIPixellate,
 CIPointillize,
 CIQRCodeGenerator,
 CIRadialGradient,  //半径梯度
 CIRandomGenerator,
 CIRippleTransition,
 CIRowAverage,
 CISaturationBlendMode, //饱和度混合模式
 CIScreenBlendMode,  //全屏混合模式
 CISepiaTone,       //棕黑色调
 CIShadedMaterial,
 CISharpenLuminance,
 CISixfoldReflectedTile,
 CISixfoldRotatedTile,
 CISmoothLinearGradient,
 CISoftLightBlendMode,   //软光混合模式
 CISourceAtopCompositing,
 CISourceInCompositing,
 CISourceOutCompositing,
 CISourceOverCompositing,
 CISpotColor,
 CISpotLight,
 CISRGBToneCurveToLinear,
 CIStarShineGenerator,
 CIStraightenFilter,   //拉直过滤器
 CIStretchCrop,
 CIStripesGenerator,   //条纹发生器
 CISubtractBlendMode,
 CISunbeamsGenerator,
 CISwipeTransition,
 CITemperatureAndTint,   //色温
 CIThermal,
 CIToneCurve,       //色调曲线
 CITorusLensDistortion,
 CITriangleKaleidoscope,
 CITriangleTile,
 CITwelvefoldReflectedTile,
 CITwirlDistortion,
 CIUnsharpMask,
 CIVibrance,   //震动
 CIVignette,   //印花
 CIVignetteEffect,
 CIVortexDistortion,
 CIWhitePointAdjust,  //白平衡调节
 CIXRay,
 CIZoomBlur
 )

 
 */
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
